<template>
    <div class="user-edit all-height">
        <div :style="{ maxHeight: maxHeight }" class="drawer-content all-height">
            <Form ref="form" :model="form" :rules="formValidate" label-position="left" :label-width="150" class="marginForm">
                <!--                <p class="drawer-title">学籍信息</p>-->
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="姓名" prop="name">
                            <Input v-model.lazy="form.name" :maxlength="50" />
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem prop="gxcode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('gxcode')">
                                <span>高校名称</span>
                            </div>
                            <Select v-model.lazy="form.gxcode" :placeholder="form.gxcodeName" @on-open-change="handleSelectDataSlice('gxcode', $event)" filterable  @on-change="handChange()">
                                <Option v-for="item in yxListSelectData" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="院系名称" prop="yxmc">
                            <Input v-model.lazy="form.yxmc" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="考生号" prop="ksh">
                            <Input v-model.lazy="form.ksh" clearable maxlength="70" />
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="学号" prop="xh">
                            <Input v-model.lazy="form.xh" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="身份证号" prop="idCard">
                            <Input v-model.lazy="form.idCard" autocomplete="off" :maxlength="50" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem prop="sexCode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('sexCode')">
                                <span>性别</span>
                            </div>
                            <Select v-model.lazy="form.sexCode" filterable  @on-create="keyUpSearch($event, 'sexCode')">
                                <Option v-for="item in sexCodeList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem prop="mzCode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('mzCode')">
                                <span>民族</span>
                            </div>
                            <Select v-model.lazy="form.mzCode" filterable  @on-create="keyUpSearch($event, 'mzCode')">
                                <Option v-for="item in mzList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem prop="zzmmCode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('zzmmCode')">
                                <span>政治面貌</span>
                            </div>
                            <Select v-model.lazy="form.zzmmCode" filterable  @on-create="keyUpSearch($event, 'zzmmCode')">
                                <Option v-for="item in zzmmList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem prop="cxsy">
                            <div class="itemLabel" slot="label" @click="clickSexCode('cxsy')">
                                <span>城乡生源</span>
                            </div>
                            <Select v-model.lazy="form.cxsy" filterable  @on-create="keyUpSearch($event, 'cxsy')">
                                <Option v-for="item in cxsyList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem prop="xlCode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('xlCode')">
                                <span>学历</span>
                            </div>
                            <Select v-model.lazy="form.xlCode" filterable  @on-create="keyUpSearch($event, 'xlCode')">
                                <Option v-for="item in xlList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem prop="zy">
                            <div class="itemLabel" slot="label" @click="clickSexCode('zy')">
                                <span>专业</span>
                            </div>
                            <Select v-model.lazy="form.zy" :placeholder="form.zyXszName" @on-open-change="handleSelectDataSlice('zy', $event)" filterable  @on-create="keyUpSearch($event, 'zy')">
                                <Option v-for="item in zyList" :value="item.value" :key="item.id">{{ item.title }}</Option>
                            </Select>
                            <!--              <Input v-model="form.zyCode" clearable :maxlength="70" @keydown.native="keyUpSearch($event,'zyCode')"/>-->
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="专业方向" prop="zyfx">
                            <Input v-model.lazy="form.zyfx" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem prop="xxxs">
                            <div class="itemLabel" slot="label" @click="clickSexCode('xxxs')">
                                <span>学习形式</span>
                            </div>
                            <Select v-model.lazy="form.xxxs" filterable  @on-create="keyUpSearch($event, 'xxxs')">
                                <Option v-for="item in xxxsList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem prop="pyfsCode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('pyfs_code')">
                                <span>培养方式</span>
                            </div>
                            <Select v-model.lazy="form.pyfsCode" filterable  @on-create="keyUpSearch($event, 'pyfsCode')">
                                <Option v-for="item in pyfsList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem prop="sydCode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('sydCode')">
                                <span>生源所在地</span>
                            </div>
                            <Select :placeholder="form.sydCodeName" v-model.lazy="form.sydCode" @on-open-change="handleSelectDataSlice('sydCode', $event)" filterable  @on-create="keyUpSearch($event, 'sydCode')">
                                <Option v-for="item in areaCodeListSelectData1" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem prop="xz">
                            <div class="itemLabel" slot="label" @click="clickSexCode('xz')">
                                <span>学制</span>
                            </div>
                            <Select v-model.lazy="form.xz" filterable  @on-create="keyUpSearch($event, 'xz')">
                                <Option v-for="item in xzList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="入学时间" prop="rxsj">
                            <Input v-model.lazy="form.rxsj" clearable maxlength="20" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="毕业时间" prop="bysj">
                            <Input v-model.lazy="form.bysj" clearable maxlength="20" />
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem prop="ffslbCode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('ffslbCode')">
                                <span>师范生类别</span>
                            </div>
                            <Select v-model.lazy="form.sfslbCode" filterable clearable  @on-create="keyUpSearch($event, 'sfslbCode')">
                                <Option v-for="item in sfslbList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem prop="knslbCode">
                            <div class="itemLabel" slot="label" @click="clickSexCode('knslbCode')">
                                <span>困难生类别</span>
                            </div>
                            <Select v-model.lazy="form.knslbCode" filterable  @on-create="keyUpSearch($event, 'knslbCode')">
                                <Option v-for="item in knslbList" :value="item.value" :key="item.value">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="所在班级" prop="szbj">
                            <Input v-model.lazy="form.szbj" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="分校名称" prop="fxmc">
                            <Input v-model.lazy="form.fxmc" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="是否52贫困县" prop="fxmc">
                            <Select v-model.lazy="form.sf52pkx">
                                <Option value="0">是</Option>
                                <Option value="0">否</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="贫困县所在省" prop="fxmc">
                            <Input v-model.lazy="form.sheng" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="贫困县所在市" prop="fxmc">
                            <Input v-model.lazy="form.shi" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                </Row>
                <Divider />
                <p class="drawer-title">个人信息</p>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="出生日期" prop="cssj">
                            <Input v-model.lazy="form.cssj" clearable :maxlength="20" />
                        </FormItem>
                    </Col>
                </Row>
                <Row :gutter="32"></Row>
                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="手机号码" prop="mobile">
                            <Input v-model.lazy="form.mobile" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                </Row>

                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="电子邮箱" prop="email">
                            <Input v-model.lazy="form.email" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="QQ号码" prop="qq">
                            <Input v-model.lazy="form.qq" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                </Row>

                <Row :gutter="32">
                    <Col span="24">
                        <FormItem prop="szdq">
                            <div class="itemLabel" slot="label" @click="clickSexCode('szdq')">
                                <span>所在地区</span>
                            </div>
                            <Select v-model.lazy="form.szdq" :placeholder="form.szdqName" @on-open-change="handleSelectDataSlice('szdq', $event)" clearable
                                    filterable>
                                <Option v-for="(item,index) in areaCodeListSelectData2" :value="item.value" :key="index">{{ item.title }}</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="家庭地址" prop="jtdz">
                            <Input v-model.lazy="form.jtdz" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem label="家庭电话" prop="jtdh">
                            <Input v-model.lazy="form.jtdh" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                </Row>

                <Row :gutter="32">
                    <Col span="24">
                        <FormItem label="家庭邮编" prop="jtyb">
                            <Input v-model.lazy="form.jtyb" clearable :maxlength="70" />
                        </FormItem>
                    </Col>
                </Row>
            </Form>
        </div>
        <!--    字典弹框-->
        <Modal  v-model.lazy="modal" :title="modalTitle"  class="modal-content cust-modal" @on-ok="clickTrue">
            <div class="modal-body-title d-flex">
                <div class="form-item">
                    <label class="form-label">代码</label>
                    <Input v-model.lazy="searchValueKeyword" placeholder="请输入搜索的代码关键字" @on-change="handleModalTitleSearch" />
                </div>
                <div class="form-item">
                    <label class="form-label">名称</label>
                    <Input v-model.lazy="searchTitleKeyword" placeholder="请输入搜索的名称关键字" @on-change="handleModalTitleSearch" />
                </div>
            </div>
            <div v-ref-height="refHight" class="modal-body-table">
                <Table  :height="refHight.value" :columns="columns" :data="dataList"  @on-row-click="handleClickRow" ref="table"></Table>
            </div>
            <div  class="modal-body-page d-flex-around-center  mt-8">
                <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" size="small" show-total show-elevator></Page>
            </div>
        </Modal>
    </div>
</template>

<script>
import { getXldmzdList } from '@/api/bys/code/xldm.js';
import { addBysPersonInfo, editBysInfo } from '@/api/bys/personInfo/bys.js';
import { getDictDataByTypeAndPage } from '@/api/index';
import { validateIDCard, validateMobileNoBt } from '@/libs/validate';
import departmentTreeChoose from '@/views/my-components/xboot/department-tree-choose';
import uploadPicInput from '@/views/my-components/xboot/upload-pic-input';
import SetPassword from '@/views/my-components/xboot/set-password';
import { getByXlAndLevelPage } from '@/api/bys/code';

export default {
    name: 'batchEdit',
    components: {
        departmentTreeChoose,
        uploadPicInput,
        SetPassword
    },
    props: {
        addOrEditLabelWidth: {

        },
        value: {
            type: Boolean,
            default: false
        },
        data: {
            type: Object
        },
        type: {
            type: String,
            default: '2'
        }
    },
    data() {
        return {
            refHight:{value:0},
            searchForm: {
                // 搜索框初始化对象
                pageNumber: 1, // 当前页数
                pageSize: 10, // 页面大小
                sort: 'createTime', // 默认排序字段
                order: 'desc' // 默认排序方式
            },
            total: 0,
            searchTitleKeyword: '',
            searchValueKeyword: '',
            areaCodeList: [], //地区代码表
            visible: this.value,
            title: '',
            passColor: '',
            submitLoading: false,
            maxHeight: 510,
            form: {},
            formValidate: {
                // 表单验证规则
                idCard: [{ validator: validateIDCard, trigger: 'change' }],
                mobile: [{ validator: validateMobileNoBt, trigger: 'change' }],
                email: [{ type: 'email', message: '邮箱格式不正确' }]
            },
            // 弹框
            modal: false,
            currentModalSearch: '',
            // 弹框标题
            modalTitle: '',
            //弹框表格
            columns: [
                {
                    title: '代码',
                    key: 'value',
                    sortable: false,
                    align: 'center'
                },
                {
                    title: '名称',
                    key: 'title',
                    sortable: false,
                    align: 'center'
                }
            ],
            defultColumns: [
                {
                    title: '代码',
                    key: 'value',
                    sortable: false,
                    align: 'center'
                },
                {
                    title: '名称',
                    key: 'title',
                    sortable: false,
                    align: 'center'
                }
            ],
            xlflColumns: [
                {
                    title: '学历分类',
                    key: 'xlflz',
                    sortable: false,
                    align: 'center',
                    render: (h, params) => {
                        let dict = this.xlccList.find(item => item.value == params.row.xllxz).title;
                        return h('div', dict ? dict : '');
                    }
                },
                {
                    title: '代码',
                    key: 'value',
                    sortable: false,
                    align: 'center'
                },
                {
                    title: '名称',
                    key: 'title',
                    sortable: false,
                    align: 'center'
                }
            ],
            zyColumns: [
                {
                    title: '学历分类',
                    key: 'xlflz',
                    sortable: false,
                    align: 'center',
                    render: (h, params) => {
                        let dict = this.xlccList.find(item => item.value == params.row.xllxz).title;
                        return h('div', dict ? dict : '');
                    }
                },
                {
                    title: '代码',
                    key: 'zyCode',
                    sortable: false,
                    align: 'center'
                },
                {
                    title: '专业',
                    key: 'zy',
                    sortable: false,
                    align: 'center'
                }
            ],
            dataList: [],
            scroll: {
                y: '200px' // 表头固定的高度
            },
            modalDict: '',
            showCode: '', //双击行传递的值
            rowList: null,
            yxList: [],
            sexCodeList: [],
            mzList: [],
            zzmmList: [],
            xlccList: [],
            xlList: [],
            xxxsList: [],
            cxsyList: [],
            pyfsList: [],
            sfslbList: [],
            knslbList: [],
            zyList: [],
            xzList: [],

            //
            yxListSelectData: [],
            areaCodeListSelectData1: [],
            areaCodeListSelectData2: [],
            zyXszSelectData: []
        };
    },

    methods: {
        // 暴漏给外部组件使用
        resetForm() {
            this.form = {};
            this.$forceUpdate();
        },
        handleSelectDataSlice(key, e) {
            console.log(key, e);
            let key1, key2;
            if (key === 'gxcode') {
                key1 = 'yxListSelectData';
                key2 = 'yxList';
            } else if (key === 'zy') {
                key1 = 'zyXszSelectData';
                key2 = 'zyList';
            } else if (key === 'sydCode') {
                key1 = 'areaCodeListSelectData1';
                key2 = 'areaCodeList';
            } else if (key === 'szdq') {
                // 专业
                key1 = 'areaCodeListSelectData2';
                key2 = 'areaCodeList';
            }
            if (e) {
                // if (key === 'gxcode') {
                //     let userInfo = JSON.parse(sessionStorage.getItem('userInfo'));
                //     let userroles = sessionStorage.getItem('roles');
                //     console.log(userroles, 'userdata');
                //     console.log(userInfo.gxcode, userInfo.gxmc, 'userInfo');
                //     if (userroles === '["ROLE_SCHOOL"]') {
                //         let yxList = [];
                //         yxList.push({ value: userInfo.gxcode, title: userInfo.gxmc });
                //         this[key1] = yxList;
                //     } else {
                //         this[key1] = this[key2];
                //     }
                // } else {
                //     this[key1] = this[key2];
                // }
            } else {
                // 这里不能为空 得按照这个值 在this[key2] 中找到item 然后放入this[key1]
                let value = this.form[key];

                let data = this[key2].find(item => {
                    return value === item.value;
                });

                if (data) {
                    this[key1] = [data];
                } else {
                    // 专业可能找不到
                    this[key] = [];
                }
            }
        },

        handleModalTitleSearch() {
            this.handleWatchModalDictData(this.currentModalSearch);
        },
        async getXlList() {
            let res = await this.postRequest('/xldmzd/getAll');
            if (res.success) {
                this.xlList = res.result;
            }
        },

        //代码按钮
        clickSexCode(e) {
            this.showCode = e;
            this.modal = true;
            this.searchTitleKeyword = '';
            this.searchValueKeyword = '';
            this.searchForm.pageNumber = 1;
            this.searchForm.pageSize = 50;
            this.currentModalSearch = e;
            this.showDict(e);
        },
        showDict(e) {
            this.columns = this.defultColumns;
            if (e == 'sexCode') {
                this.modalTitle = '性别';
                this.modalDict = 'sexCode';
            } else if (e == 'gxcode') {
                this.modalTitle = '院校名称';
                this.modalDict = 'gxcode';
            } else if (e == 'mzCode') {
                this.modalTitle = '民族';
                this.modalDict = 'mzCode';
            } else if (e == 'zzmmCode') {
                this.modalTitle = '政治面貌';
                this.modalDict = 'zzmmCode';
            } else if (e == 'xlCode') {
                this.modalTitle = '学历';
                this.modalDict = 'xlCode';
                this.columns = this.xlflColumns;
            } else if (e == 'zy') {
                this.modalTitle = '专业';
                this.modalDict = 'zy';
                this.columns = this.zyColumns;
            } else if (e == 'xxxs') {
                this.modalTitle = '学习形式';
                this.modalDict = 'xxxs';
            } else if (e == 'pyfs_code') {
                this.modalTitle = '培养方式';
                this.modalDict = 'pyfs_code';
            } else if (e == 'xz') {
                this.modalTitle = '学制';
                this.modalDict = 'xz';
            } else if (e == 'ffslbCode') {
                this.modalTitle = '师范生类别';
                this.modalDict = 'ffslbCode';
            } else if (e == 'szdq') {
                this.modalTitle = '所在地区';
                this.modalDict = 'szdq';
            } else if (e == 'knslbCode') {
                this.modalTitle = '困难生类别';
                this.modalDict = 'knslbCode';
            } else if (e == 'sydCode') {
                this.modalTitle = '生源所在地';
                this.modalDict = 'sydCode';
            }else if (e == 'cxsy') {
                this.modalTitle = '城乡生源';
                this.modalDict = 'cxsy';
            }
            this.handleWatchModalDictData(this.currentModalSearch);
        },
        handChange() {
            const selectedItem = this.yxList.find(item => item.value === this.form.gxcode);
            if (selectedItem) {
                this.form.gxmc = selectedItem.title;
            }
        },
        keyUpSearch(e, value) {
            this.showDict(value);
            if (e.keyCode == 13 || e.keyCode == 9) {
                if (value == 'sexCode') {
                    this.form.sexCode = this.sexCodeList.find(item => item.value == e.target.value).title;
                } else if (value == 'gxcode') {
                    this.form.gxcode = this.yxList.find(item => item.value == e.target.value).title;
                } else if (value == 'gxmc') {
                    this.form.gxmc = this.yxList.find(item => item.value == e.target.value).title;
                } else if (value == 'mzCode') {
                    this.form.mzCode = this.mzList.find(item => item.value == e.target.value).title;
                } else if (value == 'zzmmCode') {
                    this.form.zzmmCode = this.zzmmList.find(item => item.value == e.target.value).title;
                } else if (value == 'xlCode') {
                    this.form.xlCode = this.xlList.find(item => item.value == e.target.value).title;
                } else if (value == 'pyfsCode') {
                    this.form.pyfsCode = this.pyfsList.find(item => item.value == e.target.value).title;
                } else if (value == 'knslbCode') {
                    this.form.knslbCode = this.knslbList.find(item => item.value == e.target.value).title;
                } else if (value == 'ffslbCode') {
                    this.form.ffslbCode = this.sfslbList.find(item => item.value == e.target.value).title;
                } else if (value == 'gzkzksbz') {
                    this.form.gzkzksbz = this.gzkzksbzList.find(item => item.value == e.target.value).title;
                } else if (value == 'xxxs') {
                    this.form.xxxs = this.xxxsList.find(item => item.value == e.target.value).title;
                } else if (value == 'zy') {
                    // this.form.zyCode = this.zyList.find(item => item.value == e.target.value).title
                    this.form.zy = this.zyList.find(item => item.value == e.target.value).title;
                } else if (value === 'sydCode') {
                    this.form.sydCode = this.areaCodeList.find(item => item.value == e.target.value).title;
                } else if (value === 'cxsy') {
                    this.form.cxsy = this.cxsyList.find(item => item.value == e.target.value).title;
                }
            }
            console.log(this.form.zy);
        },
        //弹框按钮
        clickTrue(row) {
            const _this = this;
            _this.modal = false;
            if(_this.showCode === 'ffslbCode'){
                _this.form['sfslbCode'] = row.value;
                _this.form['sfslbCodeName'] = row.title;
                return;
            };
            if(_this.showCode === 'pyfs_code'){
                _this.form['pyfsCode'] = row.value;
                _this.form['pyfsCodeName'] = row.title;
                return;
            };
            const form = JSON.parse(JSON.stringify(_this.form));
            form[_this.showCode] = row.value;
            form[_this.showCode+'Name'] = row.title;
            _this.$refs.form.resetFields(); // 重置表单
            _this.$nextTick(() => {
                _this.form = form;
                _this.$forceUpdate();
            });
            // if (this.showCode==="xlCode"){
            //   this.form.xlcc = this.rowList.xllxz ? this.rowList.xllxz: ""
            // }else if (this.showCode === "gxcode"){
            //   this.form['gxmc'] = this.rowList.title
            // }
            if (this.showCode == 'gxcode') {
                this.form['gxmc'] = this.rowList.title;
            }
        },
        changePage(v) {
            this.searchForm.pageNumber = v;
            this.handleWatchModalDictData(this.currentModalSearch);
        },
        // table
        handleClickRow(row) {
            this.rowList = row;
            this.clickTrue(row);
        },

        submit(e) {
            this.$refs.form.validate(valid => {
                if (valid) {
                    // this.form.mobile = this.getMockMobile();
                    if (typeof this.form.birth == 'object') {
                        this.form.birth = this.format(this.form.birth, 'yyyy-MM-dd');
                    }
                    try {
                        this.form.zy = this.zyList.find(item => item.value == this.form.zy).zy;
                        this.form.zyCode = this.zyList.find(item => item.value == this.form.zy).zyCode;
                    } catch (e) {}
                    // this.form.jb = new Date(this.form.jb).getFullYear()
                    if (this.type == '1') {
                        // 编辑
                        this.submitLoading = true;
                        editBysInfo(this.form).then(res => {
                            this.submitLoading = false;
                            if (res.success) {
                                this.$Message.success('操作成功');
                                this.$emit('on-submit', true);
                                this.visible = false;
                                this.cancel();
                            }
                        });
                    } else {
                        // 添加
                        this.submitLoading = true;
                        addBysPersonInfo(this.form).then(res => {
                            this.submitLoading = false;
                            if (res.success) {
                                this.$Message.success('操作成功');
                                this.$emit('on-submit', true);
                                this.visible = false;
                                this.cancel();
                            }
                        });
                    }
                }
            });
        },
        cancel(e) {
            this.$emit('open-search', true);
        },
        handleWatchModalDictData(e) {
            this.dataList = [];
            if (e == 'sexCode') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'sex', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            } else if (e == 'mzCode') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'ethnic', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            } else if (e == 'zzmmCode') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'political', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            } else if (e == 'xlCode') {
                getXldmzdList({ ...this.searchForm, xldm: this.searchValueKeyword, xl: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.records.map(el => {
                            return {
                                value: el.xldm,
                                title: el.xl,
                                xllxz: el.xllxz
                            };
                        });
                        this.total = res.result.total;
                    }
                });
            } else if (e == 'zy') {
                getByXlAndLevelPage({ ...this.searchForm, value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.records.map(el => {
                            return {
                                xllxz: el.gradLevelDict,
                                value: el.profCode + el.title,
                                title: el.profCode + el.title,
                                zy: el.title,
                                zyCode: el.profCode
                            };
                        });
                        this.total = res.result.total;
                    }
                });
            } else if (e == 'xxxs') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'learning-forms', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            } else if (e == 'pyfs_code') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'training-methods', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            } else if (e == 'xz') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'educational-system', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            } else if (e == 'ffslbCode') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'sfs_type', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            } else if (e == 'knslbCode') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'difficult-student-category', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            } else if (e == 'sydCode') {
                this.postRequest('/areaCode/getByPage', { ...this.searchForm, code: this.searchValueKeyword, displayName: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.records.map(e => {
                            return { value: e.code, title: e.displayName };
                        });
                        this.total = res.result.total;
                    }
                });
            } else if (e == 'szdq') {
                this.postRequest('/areaCode/getByPage', { ...this.searchForm, code: this.searchValueKeyword, displayName: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.records.map(e => {
                            return { value: e.code, title: e.displayName };
                        });
                        this.total = res.result.total;
                    }
                });
            }else if (e == 'gxcode') {
                this.postRequest('/schoolCode/getByPage', { ...this.searchForm, code: this.searchValueKeyword, name: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.records.map(e => {
                            return { value: e.code, title: e.name };
                        });
                        this.total = res.result.total;
                    }
                });
            } else if (e == 'cxsy') {
                getDictDataByTypeAndPage({ ...this.searchForm, type: 'cxsy', value: this.searchValueKeyword, title: this.searchTitleKeyword }).then(res => {
                    if (res.success) {
                        this.dataList = res.result.content;
                        this.total = res.result.totalElements;
                    }
                });
            }
        }
    },
    watch: {
        modalDict(e) {
            return this.handleWatchModalDictData(e);
        }
    }
};
</script>
<style lang="less" scoped>


.cust-modal {
    /deep/.ivu-modal {
         width: 30% !important;
     }
 }
/deep/ .ivu-select-dropdown {
    //display: none;
}

.form-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    margin-right: 15px;
}

.form-label {
    margin-right: 10px;
    width: 40px;
}

.page {
    margin-top: 20px;
}

/deep/ .ivu-select-arrow {
    display: none;
}

@import './../../personInfo.less';

.ivu-form-item {
    margin-bottom: 0.1rem;
}

.ivu-input-prefix {
    top: 0.03rem;
}

.itemLabel {
    span {
        color: rgb(55, 140, 254) !important;
        cursor: pointer;
    }
}

.selected {
    background-color: #f5f7fa;
}

.modalTable {
    width: 100%;

    thead {
        width: 100%;

        tr {
            width: 100%;

            th {
                width: 50%;
            }
        }
    }

    tbody {
        width: 100%;

        tr {
            width: 100%;
        }
    }
}

/deep/ .ivu-table {
    .ivu-table-body {
        height: 450px !important;
        overflow-y: scroll;

        .ivu-table-row {
            &:hover {
                .ivu-input {
                    background: rgb(235, 247, 70);
                }
            }
        }

        .ivu-input {
            border: none !important;
            cursor: default;

            &:hover {
                border: none !important;
                background: rgb(235, 247, 70);
            }
        }
    }
}
</style>
<style lang="less">
@import '../../../styles/drawer-common.less';
@import '../../personInfo.less';

.modal-content{
    
    // width: 520px;
    height: 700px;
    .modal-body-title{
        height: 40px;
    }
    .modal-body-table{
        height: 480px;
    }
    .modal-body-page{
        height: 40px;
    }
    
}


.ivu-form-item {
    margin-bottom: 0.1rem;
}

.form-label {
    margin-right: 10px;
    width: 40px;
}

.form-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    margin-right: 15px;
}

.ivu-input-prefix {
    top: 0.03rem;
}
</style>
